package com.rm.zeyou.service.impl;

import com.rm.zeyou.entity.Feedback;
import com.rm.zeyou.mapper.FeedbackMapper;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.FeedbackService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rm.zeyou.vo.request.AddFeedbackVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 意见反馈表 服务实现类
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:08
 */
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements FeedbackService {
    @Resource
    private FeedbackMapper feedbackMapper;

    @Transactional(rollbackFor = RuntimeException.class)
    @Override
    public ApiRestResponse<Integer> addFeedback(Long userId, AddFeedbackVo addVo) {
        Feedback insertFeedback = new Feedback();
        insertFeedback.setUserId(userId);
        insertFeedback.setFeedbackType(addVo.getFeedbackType());
        insertFeedback.setFeedbackTel(addVo.getFeedbackTel());
        insertFeedback.setFeedbackContent(addVo.getFeedbackContent());
        insertFeedback.setFeedbackPicture(addVo.getFeedbackPicture());
        int insert = feedbackMapper.insert(insertFeedback);
        return ApiRestResponse.success(insert);
    }
}
